<template>
	<view class="login">
		<form action="" method="get">
			<input class="code" type="text" placeholder="请输入手机号" v-model="phone">
			<view style="clear: both;"></view>
			<input  class="code" type="text" placeholder="请输入密码" v-model="password">
		</form>
			<input class="sendCode" type="button" value="登陆" @click="login()">
	<view style="clear: both;"></view>
	<button class="l" @click="tologin()">验证码登陆</button>
	<button class="l" @click="toregister()">注册账号</button>
	
	</view>
</template>

<script>
	export default{
		name:"loginBypassword",
		data(){
			return{
				phone:'',
				password:''
			}
		},
		methods:{
			login(){
				uni.request({
					url:"http://" + getApp().globalData.IpAddr + "/user/loginByPassword",
					method:"POST",
					data:{'phone':this.phone , 'code':this.code , 'password':this.password},
					success:res => {
						console.log(res)
						if(!res.data.success) {	wx.showToast({	title: res.data.errorMsg,	duration: 2000	})	}
						else {
							getApp().globalData.token = res.data.data
							uni.reLaunch({	url: "/pages/index/modules/recommend"	})
						}
					}
				})
			},
			toregister(){
				uni.navigateTo({
					url: "/pages/ext/register"
				})
			},
			tologin(){
				uni.navigateTo({
					url: "/pages/ext/login"
				})
			}
		}
	}
</script>

<style>
	.l{
		width: 40vw;
		font-size: 5vw;
		float: right;
		margin-top: 3vw;
		margin-right: 10vw;
		background-color: #fff;
	}
	.login{
		width: 100vw;
		height: 100vh;
		background-color: #f7f5f5;
		padding: 3vw;
	}
	.iphoneNumber{
		background-color: #ffffff;
		border-radius: 5px;
		width: 45vw;
		float: left;
		color: #c4c4cc;
		padding: 3vw;
	}
	.send{
		background-color: #27c21c;
		border-radius: 5px;
		width: 25vw;
		padding: 3vw;
		float: left;
		margin-left: 5vw;
		color: white;
		text-align: center;
	}
	.code{
		background-color: #ffffff;
		border-radius: 5px;
		width: 90vw;
		color: #c4c4cc;
		padding: 10px;
		margin-top: 10px;
	}
	.sendCode{
		background-color: #27c21c;
		border-radius: 5px;
		margin-top: 50px;
		width: 70vw;
		padding: 3vw;
		float: left;
		margin-left: 5vw;
		color: white;
		text-align: center;
	}
</style>